# Maintainer: Dylan Van Assche <me@dylanvanassche.be>
pkgname=hexagonrpcd
pkgver=0.3.2
pkgrel=1
pkgdesc="Qualcomm HexagonFS daemon"
url="https://gitlab.com/sdm670-mainline/hexagonrpc"
# s390x: fails on 1 test. Hexagonrpcd is specific to Qualcomm ARM SoCs, so let's ignore it for now.
arch="all !s390x"
license="GPL-3.0-or-later"
makedepends="linux-headers meson"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"

source="https://gitlab.com/sdm670-mainline/hexagonrpc/-/archive/v$pkgver/hexagonrpc-v$pkgver.tar.gz
	10-fastrpc.rules
	$pkgname-adsp-rootpd.initd
	$pkgname-adsp-sensorspd.initd
	$pkgname-sdsp.initd
	$pkgname.confd
	"
builddir="$srcdir/hexagonrpc-v$pkgver"

build() {
	abuild-meson \
		-Db_lto=true \
		-Dhexagonrpcd_verbose=false \
		. output
	meson compile -C output
}

check() {
	meson test -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	# Allow access for FastRPC node for FastRPC user/group
	install -Dm644 "$srcdir"/10-fastrpc.rules -t "$pkgdir"/usr/lib/udev/rules.d/

	install -Dm755 "$srcdir"/$pkgname-adsp-rootpd.initd "$pkgdir"/etc/init.d/$pkgname-adsp-rootpd
	install -Dm755 "$srcdir"/$pkgname-adsp-sensorspd.initd "$pkgdir"/etc/init.d/$pkgname-adsp-sensorspd
	install -Dm755 "$srcdir"/$pkgname-sdsp.initd "$pkgdir"/etc/init.d/$pkgname-sdsp
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname-sdsp
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname-adsp-rootpd
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname-adsp-sensorspd
}


sha512sums="
4d6171b2bbbb2df93a1324daafe0b279728531ae7c0b5e218a93de0ae6097f9c651ed416185b61ac276db28eb4d2b652a8636d65f34e34c03a4d7f9b2aee8fd0  hexagonrpc-v0.3.2.tar.gz
f931cf5f901a7c17ffb0eb194b5de2c532fd238692898bf264c484b13b93119c9727bd8f8daf6a7d1668cc9108a9a0662231d300c6f1376e3e4edd3ce41d235d  10-fastrpc.rules
4ccabf6579ff1bb42d1875a51eddb9884bc65ed60eed723f7747ac6abea7b3a7acf05cfe3bf66a13bec6e22f7bbf48e88b598457286d738fd03e0a69f9263b67  hexagonrpcd-adsp-rootpd.initd
971557a233b9bf7386a8c3641b318b81b38647004eb54687a69a1b5c44506acd7c7cc23d038f3a3ba5c8fcfe191440ce0a06d6e5f42d798da18b7683e2d89a8b  hexagonrpcd-adsp-sensorspd.initd
7e9153046370f6a8dd6c6686702866be192364a111216900256a666d726ad97a0cda88f682b18476ea74532081c6e961018529c5213719e1f34f104257a9a4a1  hexagonrpcd-sdsp.initd
e989e45853e2abd17c16ec7cdf9990f4a4ade5a36bb798fb28d5ce8cd264fe693699b196b240cfe3c83949f6931488a59aa446d43b263e168fa3758a5754a71a  hexagonrpcd.confd
"
